# !/bin/bash
apt-get update
apt-get install aptitude -y
aptitude update
aptitude install subversion apache2 mysql-server php5 php5-mysql -y

file_contents='
<VirtualHost *:80>\n
	ServerAdmin webmaster@localhost\n

	DocumentRoot /var/www\n
	<Directory />\n
		Options FollowSymLinks\n
		AllowOverride None\n
	</Directory>\n

	<Directory /var/www/>\n
		#Options Indexes FollowSymLinks MultiViews\n
		#AllowOverride None\n
		#Order allow,deny\n
		#allow from all\n
		Options FollowSymLinks MultiViews\n
		AllowOverride All\n
		Order allow,deny\n
		allow from all\n
		RewriteEngine on\n
		RewriteRule ^$ galactus/gtm [L]\n
	</Directory>\n

	<Directory /var/www/galactus/gtm>\n
		Options FollowSymLinks MultiViews\n
		AllowOverride All\n
		Order allow,deny\n
		allow from all\n
		RewriteEngine on\n
		RewriteCond %{REQUEST_FILENAME} !-f\n
		RewriteCond %{REQUEST_FILENAME} !-d\n
		RewriteRule ^(.*)$ index.php [QSA,L]\n
	</Directory>\n

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/\n
	<Directory "/usr/lib/cgi-bin">\n
		AllowOverride None\n
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch\n
		Order allow,deny\n
		Allow from all\n
	</Directory>\n

	ErrorLog ${APACHE_LOG_DIR}/error.log\n

	# Possible values include: debug, info, notice, warn, error, crit,\n
	# alert, emerg.\n
	LogLevel warn\n

	CustomLog ${APACHE_LOG_DIR}/access.log combined\n

    Alias /doc/ "/usr/share/doc/"\n
    <Directory "/usr/share/doc/">\n
        Options Indexes MultiViews FollowSymLinks\n
        AllowOverride None\n
        Order deny,allow\n
        Deny from all\n
        Allow from 127.0.0.0/255.0.0.0 ::1/128\n
    </Directory>\n

</VirtualHost>\n
'

echo -e $file_contents > /etc/apache2/sites-available/default
a2enmod rewrite
service apache2 restart

cd /var/www/
svn checkout http://galactus.googlecode.com/svn/trunk/ galactus
chown -R www-data:www-data /var/www/galactus
chmod 744 -R /var/www/galactus

mysql -p < /var/www/galactus/gtm/galactus.sql

aptitude install yasm nasm -y

wget http://www.ffmpeg.org/releases/ffmpeg-1.2.tar.gz
tar -vzxf ffmpeg-1.2.tar.gz
cd ffmpeg-1.2
./configure
make
make install
cd ..
rm -rf ffmpeg-1.2
rm ffmpeg-1.2.tar.gz
